<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .main {
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
<div class="main"></div>
<script type="text/javascript">
    let main = document.querySelector(".main");
    let colorArr = ["red", "green", "blue", "yellow"];
    for (let i = 0; i < colorArr.length; i++) {
        setInterval(function () {
                main.style.backgroundColor = colorArr[i]
            }
            , 1000)
    }
</script>
</body>
</html>